<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('电话工单初稿列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="notice-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNo"/>
                        </li>
                        <li>
                            来电号码：<input type="text" name="fromTelA"/>
                        </li>
                        <li>
                            来电人：<input type="text" name="fromName"/>
                        </li>
                        <li>
                            地区名称：<input type="text" name="fmAreaName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
<!--            <a class="btn btn-success" onclick="$.operate.addTab()">-->
<!--                <i class="fa fa-plus"></i> 新增-->
<!--            </a>-->
            <a class="btn btn-primary single disabled" onclick="tWFormUpdate()">
                <i class="fa fa-edit"></i> 编辑
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.handleTab()">
                <i class="fa fa-edit"></i> 处理
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/workForm";
    var createFlag = prefix + '/toAdd';
    var editFlag = prefix + '/workFormProcess/{id}';
    var removeFlag = prefix + '/remove';

    $(function () {
        var options = {
            url: prefix + "/twfDraftListJson",
            modalName: "电话工单初稿",
            uniqueId: "pkId",
            createUrl: createFlag,
            removeUrl: removeFlag,
            updateUrl: editFlag,
            fixedColumns: true,
            fixedNumber: 1,
            fixedRightNumber: 1,
            columns: [{
                checkbox: true
            }, {
                field: "pkId",
                title: "工单编号",
                visible: false
            },
                {
                    field: 'workFormNo',
                    title: '工单编号',
                    align: 'center',
                    sortable: true
                },
                {
                    field: 'setProId',
                    title: '性质',
                    align: 'center',
                    formatter: function (value, row, index) {
                        switch (value) {
                            case 11:
                                return "普通";
                            case 21:
                                return "督办"
                            case 31:
                                return "呈批"
                        }
                    }
                },
                {
                    field: 'wsTopic',
                    align: 'center',
                    title: '主题'
                },
                {
                    field: 'fmAreaName',
                    align: 'center',
                    title: '属地'
                },
                {
                    field: 'fromName',
                    align: 'center',
                    title: '来电人',
                },
                {
                    field: 'fromTelA',
                    align: 'center',
                    title: '来电号码'
                },
                {
                    field: 'dfmClaName',
                    align: 'center',
                    title: '诉求类型'
                },
                {
                    field: 'iptTime',
                    align: 'center',
                    title: '创建时间'
                },
                {
                    field: 'openFrom',
                    align: 'center',
                    title: '同意公开',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return "否"
                        } else {
                            return "是"
                        }
                    }
                },
                {
                    field: 'wfLimit',
                    align: 'center',
                    title: '办理时限',
                    formatter: function (value, row, index) {
                        var str = '';
                        if(value && value.length > 10) {
                            str = value.substring(0,10);
                        }
                        else {
                            str = value;
                        }
                        return str;
                    },
                    sortable: true
                },
                {
                    field: 'crtStepName',
                    align: 'center',
                    title: '当前环节'
                },
                {
                    field: 'mark',
                    align: 'center',
                    title: '是否紧急',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.fromName === '110转接' || value === '1') {
                            return '<div class="spLRed">是</div>'
                        } else {
                            return '否'
                        }

                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '"  onclick="$.operate.handleTab(\'' + row.pkId + '\')"><i class="fa fa-edit"></i>处理</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" onclick="$.operate.remove(\'' + row.pkId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function tWFormUpdate() {
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        $.modal.open('编辑工单初稿', "/system/mTelWF/cmnFile/tWFormUpdate/" + rows);
    }
</script>
</body>
</html>
